<template>
  <button
    :method="method"
    :class="{current: method === curMethod}"
    @click="changeMethod"
  >
    {{ innerText }}
  </button>
</template>

<script>
export default {
    name: 'CalButton',
    props: {
        innerText: String,
        method: String,
        curMethod:String
    },
    methods: {
      changeMethod() {
          // 'CHANGE_METHOD' 是事件类型，在actions中注册了的
            this.$emit('dispatch','CHANGE_METHOD', this.method);
        }
    }
}
</script>

<style>
.current {
    background-color: orange;
    color:#fff
}
</style>
